﻿using System;
using System.IO;
using TaiwuModdingLib.Core.Plugin;
using TaiwuModFramework.Common;
using TaiwuModFramework.Common.Abstract;
using TaiwuModFramework.Common.Base;
using TaiwuModFramework.Frontend;

namespace TaiwuModFramework.Backend {

    [PluginConfig("太吾MOD框架", "gyl", "1.0.0")]
    public class BackendEntrance : TaiwuRemakePlugin {

        private static ALogger Log { get { return FwDomain.Log; } }
        private static AReqClient ReqClient {get {return FwDomain.ReqClient; } }

        public override void Dispose() {

        }


        public override void Initialize() {
            if(FwDomain.ModIdStr != null) return;
            // 初始化框架域
            FwDomain.Init(ModIdStr);
            Log.Info("FwDomain初始化完成");
            FwDomain.FrontendInfo("框架后端开始初始化");
            // 尝试清除之前日志文件内的内容
            FwDomain.ClearLog();
            // 注册组件
            PluginEntrance.AddPlugin(this.ModIdStr, this.PluginName, new CompConfig());
            FwDomain.FrontendInfo("框架后端初始化完成");
        }
    

        


        

        public override void OnModSettingUpdate() {
            try {
                PluginEntrance.OnModSettingUpdate();
            } catch(Exception e) {
                Log.Error(e);
            }
            
        }

        public override void OnEnterNewWorld() {
            try {
                PluginEntrance.OnEnterNewWorld();
            } catch(Exception e) {
                Log.Error(e);
            }
            
        }

        public override void OnLoadedArchiveData() {
            try {
                PluginEntrance.OnLoadedArchiveData();
            } catch(Exception e) {
                Log.Error(e);
            }
            
        }
    }
}
